refactor some video code