Fix nil cannot be coerced into Fixnum error