Moved duplllicated code from activity and widget to service