refactoring angular code