refactored to use scan instead of a hash