Refactor foreground service