Added id first and last conditionals instead of using count.

This just looks a bit cleaner.