fixed problem with boundaries