modification of wp scripts made by everett1992