Is there a 'best' way for optimizing code?