Reordered code in kernel.cu to avoid statement unreachable warning