moving branch code into classes