script to detect rems