added credit calculation