this is a mess..but I might be getting somewhere