Changed the db queries to something I am familiar with.