code cleanup
add a task scheduler