added  return statement for 1d
wrote 1e with a helper function