refactoring/ cleaning a bit this mess