Updated SD filter funtion and bash script