this is one of those simple bugs that takes 3 hours to find