Linear Regression: Refactor code

Refactored some of the code to handle array input