Edited logic edit function