updated code with background