js sleep function hack to simulate blocking delay