added a timer and code to run in background