added automatic plane selection