call funtion instead of setting attributes directly