refactored some angular stuff to not require scope.apply invocation