tried to make the fallback code a bit more reusable, but getting errors