updated code with some additional angular helpers