changing some structure based on research into AngularJS best practices.