function implementation and commenting