Refactoring Angular JS elements