TODO: fix master and slave