Updated to work with 3.7 and 64 bit ruby

Refactor command selector and isolate the code to determine executable in one place.
Thanks @nanliu fixed