added additional debugging and logging