Moved function to a service