Improved retrieving of attributes value, but still buggy