Refactor to self running script