Refactor to better organize Angular code