ruby could have done this in 1 line