fix error at penalty calculation