Refactored using angular