Small refactor of script.