corrected returns and error handles