Refactored controllers / put ajax calls in factory