code for add attribute method