refactored gallery animation