start of credit function