Removed hard call to window in favor of check on last page