bug fix to databases query plus adding expand all link