added debugging code and commented out  query which is causing exception in release mode only