add penalty calculation