finished writing the rectangle checking code