Refactored code and added custom gallery for processed images