using alternative to setTimeout