added dependency injection to the controller and used $http service