added errors handling