Refactored view and moved logic into AngJs controller