Implement event flow
Format code