Issue-141 Improving DB query function