use .$apply(fn) rather than .$apply() for better exception handling