Added check for null children