refactor monitorservice for optimization