complete refactor of scripts