fixed implementation to pass test