change code to use more of angular's best practices