Fixed logic broken by previous changes