this works finally somehow, sorry for the bad code here