Add threshold parameter, add function to clean selection dir