Shortened Code a bit, still all testcases passed