added a test case; updated the code for a possible bug, but could not get it solved in web