db and query working