completed both functions