Complete PE5 (simple inefficient solution)