some ugly stuff
a silly bug, the code should work now