fix sometimes referencing nil values