nasty but it works