Solved strange behavior from testcases 3, 5, 6