refactor a large part of the code and implement configuration