some exception handling added