struggling to debug this