fix value checking bugs