refactor to use 'any' and 'all' methods on the iterator in collision check functions
restore the terminal when TerminalRestorer goes out of scope, instead of using restore() method