fixed a bug when small galleries are loaded