refactor some scripts