implemented both functions