Refactoredway of updating attributes