added limitation to number of ghosts