update
implement locks and a few other things