Updated routine logic