Cleaned up SQL Query a bit