implement as-pattern