added response code tracking and function getLastResponseCode() to return it