improved code for warnings