Attempting to Fix Query Logic