Using angularjs to its potential, removed the junk code