1-st version of worked code using thrust