Added extra security and fallbacks if something goes wrong