Added some fail safes