Added refactoring for Angular JS