refactored image controller