fixed WPmode function