Fully implemented factory pattern, works correctly on most routes