working on c version