shifting functionality into the service javascript file