errors handling added