fixed apply related bugs