refactor into multiple states