fixed sometimes referencing nil values