refactor code as class running