Made on click functions more efficient