Implemented weighted random sampling