Refactor Angular Code