added awaitKey function