completed assignment with both functions