tested and a few corrections to do