refactored Angular code