changed script for monitor detection