setimmediate re-factoring