refactoring modal logic
more refactoring
Merge pull request #2 from samcorcos/refactor

Refactor