Fixed monitor script  bugs