added plane logic and object oriented code