clean up and clarify SQL queries
drop unnecessary variables that weren't doing anything