added c version of save