added slave, refactoring