Bug fix. Added logging