Please Edit your post and wrap your code with
<YOUR CODE HERE> to get highlighting.
Its hard to read your unformatted code.
Which method is the second one? Reading through your code makes it hard...