I don't think this elif logic is quite right...