change the name of the variable as per the scope
minnor bug fixes after the test cases
corrected and added few more test cases