Added plane and refactored code