created toggleRemove function to reduce redundancy