added logging in for debug mode