refactored to include hash