Moved objective function to utilities