optimized, added use of parameters
removed unncessary parts of plane extraction