refactored util. Async instead of setTimeout