removed unused variable
Update logic with unit test.