Help optimizing a function

OK...my code won't work then.