fix attribute writer. Fixes #491