Fixed a bug that was caused by optimization