Added logic to handle invalid CSS class names