refactor & examples from w3