Added protection functions. #1 #2