modified gallery behavior