using factories and .then

changed structure of services and controllers