Added some conditions for exiting if something fails