added checks to prevent