Refactoring depend on weights