optimize both codes to see what difference it makes