finally have a working but ugly version