fix nil reference crash