Shouldn't you check if `location` is defined instead ? We've had issues with this... :-)