code function apparently complete.
I'll adapt main.c to test it.