Error checking added, removeEntry corrected.