Added logging into logic