Trying to get optimize function to work properly. Still getting a low accuracy