Refactor - separate script from java