rewrite main scripts in ruby; sh to delete