Added function to replace objective function