Corrected bug to ensure all tests pass