using promise in gallery module, fix a small bug