adds background and cleans up code