Added logic for active master

gets rid of inactive masters