read position from the json service. Refactor some code, add comments for clarity