Thank you ronjonp so much for your great help.
I knew that it has something to do with grread but it is above my head.
Your function seems to work but I couldn't test it correctly because it continues printing the message to command line without a pause.
Can you please rectify it?