still working on the restructuration of the code, seems to work for the moment but be really carefull when touching to pointer arithmetic parts