use of  function to avoid duplication