Common function for service