Switching to Angular; reduced javascript code