Added check for empty ranges in with-window