checkBoundaries method added; probs needs more
comments added