Can you clarify what you don't understand? If not, perhaps you could read some tutorials and come up with some specific questions? It would be possible for someone else to rewrite your code to do the checks you suggest, but that would leave you stuck with using code you might not understand.