Final refactor of phantomjs run script