added optimization of more functions