finally managed to figure this out