Is this the correct approach as it is only passing 1 testcase?