fix undefined method success? for nil:NilClass problem