solve bug in wait that would not update the database