fixed some bugs which caused a singular matrix, the enviroment variables are essential, still not completely sure which one exactlöy