Refactored Angular code