Clean up the code, still need to refractor to make use of angular functionality