Working script with required checks