refactored code to use weights