finally got it to work reasonably