cleaned up and made more Rubyish