WIP script refactor