Added some log and checkings