refactor C programs