added check to avoid "cutting off" of feature corners