Made the ruby code do most of the work/heavy-lifting.