bug fix
primitive locking, must be reviewed