refactor, now no apple script will be used