Optimize code; logic not changed.