Added more things to te algorithm (which I dont know if they work.)