WOW this is a mess... But it 'works'