tidy up ruby implementation