sort of works but needs logging debugged