[MODIFIED] Code optimization.