Added main functionality
Final Code