Re-organized variables and corrected the functionality of the service