refactored model and directive and hash