Adjusted condition, added logging, renamed  to something more descriptive