Refactor to use packages and improve example