emulate ruby script