adding some exception handling