refactor script parsing into class