cleanup and refactoring

using $http service for xhr call