completed handler updated; status code handling added