refactor video code