refactyoring brokers and agents