refactor, implementation and sanitization