refactored cuda