before refactor pattern match