Refactor code to use attribute reader, writer and accessor.