we should probably cache `$(document)` in an intermediate variable; we're accessing that quite a bit