modifying defensive programming, deleting extra functions and extra text