You might want to revisit this and make it more ruby-like. Also add more tests for this, because it should've picked up the failures.