Added check for nil