avoid sync methods and access stdin a better way

Hi,

I made some changes from your code.
I think this can be useful for everyone using your module.

cheers