Added some error safety.