a C version - still not working