fixed testcases
optimization