Write code for both functions