Fix for NilClass error