finally fixed the programme crash