fix optimization for penalty