Semi-working version which should be good enough