finished implementation

still some optimalisation to be done