Refactor

linting and refactor, not tested ;)