adapted a more generic, customizable and friendly script