Modified thread model: used ->insert instead of ->query