added cuda error checking