added some more checks and excepts