cleaned up solution for penalty model