publich script. refactor