added interval control, fixed some boundary conditions