move almost function to the clib.c