Fixed bugs in cropping the domain