fixed some errors, but probably unsigned int N is the problem