Fix nil reference crash