second try - using hashes - seems to work much better