changed the penalty function so that it scales with the magnitude of the error