refactor factories and dependencies