more refactoring, convert to use thrust vectors