credit logic added