refactor the get function