refactored angular controller to consolidate api calls and scope