further tweeking and debugging