Changes made to database access
Attempted to improve query, doesn't work properly yet.