This was already fairly ugly - why the need to catch ValueError here too?