fixed db query on device