Function to set attribute