added autoapply functionality