improve spinner logic