refactoring the funciton to geo ns, adding junit test cases