Code Updated For Query Issue