Refactored angular to make it more dynamic