Added improved logging