Uses match to limit the events going to the window

Simplifies the code a little bit by limiting the events that are sent to the window via the match in-built.