modified the script for monitor