updated master/slave code working