refactored question generator