Need to adapt more queries for sqlite