Rewritten version of a script presented in Using capability detection article