Made the conditional more straightforward
Protect against malicious requests, like requests with very large or negative dimensions.
Also moved fetch into its own file so it's easier to find.