Added main logic