refactored get endpoint