refactor in order to allow asynchronous calls