cleaned up and made foreground work