added loop.setTimeout and loop.setInterval to mimic js