fixed bug in [[<- method and replication of code in unifiied.R