Enhanced Script with checks