fixed broken sql query and added print statement to help future debugging