restructured the angular code to be sane