refactoring some js

re-looking at the angular js process and refactoring some js files