refactored code to make use of local storage and authentication with moodle token