Fixed error and potential crash.