refactor credit.c