Move attribute parsing to a function