Tested code and added statements to queries