fixed issue where out-of-bounds areas are not cleared