background and foreground communicating correctly