Fixed nil-related bug