hack fix for the by Ref  function call (need cleaner solution)