my perfect implementation of P6