Made some optimalizations