Keep ruby 1.9 compatibility

I've refactored the code to use a hash so it will be compatible with Ruby v. 1.9