Fixed queries to match new db format