angular code restructure and refactoring