Copied parts of HTS08's script