refactored into separate files, fixed inability to get out of check by capturing