fix this logic a bit