Added main code from SW