refactor data call to to_hash