First version of monitor code