Fixed an undefined method on NilClass error.