sort of cleaned up the code, but it does not work at the moment