refactor to use hash instead of classes