moved window handling to separate module to simplify example