This function seems a bit fragile