wrote both functions