Refactor code and use ngResource, MUCH better than simple $http