Added some debug conditions and made a log