working copy! still have to make some tweaks, look over tests and add edge cases
one change in main.rb