fix category bug, add credit logic