ruby could be better at this