Optimize an if with adds