refactor images controller