Added penalty function