fixed major bug in the algorithm, now doesnt give center is nill errors