Thanks crashtest. In answer to your last comment, yes this is an assignment for university, but you may be able to tell I really want to understand the code and not merely get somebody else to do the work and then hand it in, hence asking for an explanation. The aim of any course should ultimately be to understand better the subject, I think the awarding of marks (or not) is not always a good indicator of this process, but failure often is an indicator of a lack of understanding. I did not mean to decieve you, if you are dissapproving I sincerely apologise. Thanks again!