fixed some variables and boundary problems