working on PIE version
tidying