diff --git a/src/Buffer.hpp b/src/Buffer.hpp
index faa63d1..439db8c 100644
--- a/src/Buffer.hpp
+++ b/src/Buffer.hpp
@@ -48,6 +48,10 @@ namespace groove {
 		std::string& at(int line) {
 			return this->lines.at(line);
 		}
+
+		unsigned long size() {
+			return this->lines.size();
+		}
 	};
 
 }
\ No newline at end of file
diff --git a/src/Editor.cpp b/src/Editor.cpp
index 539da58..a76652f 100644
--- a/src/Editor.cpp
+++ b/src/Editor.cpp
@@ -110,6 +110,7 @@ namespace groove {
 							this->y++;
 							this->buffer->linebuffer().at(this->y) += appendix;
 							this->x = 0;
+							this->scrollDown();
 						}
 						break;
 					case KEY_BACKSPACE:
@@ -133,6 +134,7 @@ namespace groove {
 								}
 							}
 						}
+						scrollUp();
 						break;
 					case KEY_DC:
 						if (this->buffer->at(this->y).length() > this->x)
@@ -198,7 +200,7 @@ namespace groove {
 		int space = Editor::Digits(this->buffer->linebuffer().size()) + 2;
 		clear();
 		for (int i = 0; i < LINES - 1 + this->offset; i++) {
-			int ln = std::sqrt(std::pow(static_cast<double>(this->y - linenumber), 2));
+			int ln = static_cast<int>(std::sqrt(std::pow(static_cast<double>(this->y - linenumber), 2)));
 			ln = ln == 0 ? linenumber : ln;
 			if(i >= this->buffer->linebuffer().size()) {
 				move(i - this->offset, 0);
diff --git a/src/Editor.hpp b/src/Editor.hpp
index 723058f..7c7cbff 100644
--- a/src/Editor.hpp
+++ b/src/Editor.hpp
@@ -31,7 +31,7 @@ namespace groove {
 				this->offset--;
 		}
 		void scrollDown() {
-			if (this->y >= LINES - 1)
+			if (this->y - this->offset >= LINES - 1 && this->y < this->buffer->size())
 				this->offset++;
 		}
 		void left() {
@@ -55,7 +55,7 @@ namespace groove {
 			this->scrollUp();
 		}
 		void down() {
-			if (this->y + 1 < this->buffer->linebuffer().size())
+			if (this->y + 1 < this->buffer->linebuffer().size() )
 				this->y++;
 			else {
 				return;