added foreground and background
added some event listener