Changed structure to AngularJS