Move code to service