Nan errors and the like. I am getting nowhere