refactor and add #settings endpoint