wtf it works, albeit inefficiently