Added check to prevent crash