refactor + reformat code