added more guarantee to get right repsonse code