own implementation based on exercise