Replaced simpler version with version that includes  function