added support to waiting function