gallery script bugfix