Fixing a NilClass error