switched to C version