somehow the function retruns Nil objects producing  undefined method + nil:NilClass (NoMethodError). preventing this by adding couple prints