improved script mode check