return error code if not successful
IMP: return error code if not successful (rupaschomaker)