Fix bug with attributes, they're using previous value