made both function less glitchy