exeption handling added