it's a bit of a mess, but it workssss