Moving util functions to the Angular service