bit tidier but still generic