its a bit mess but its working