Added an optimization. + tested