Please format your code properly - very difficult to read otherwise.
How to format your code in forum posts.