Minor bug fix

Cleaned up declaration of a variable that's no longer in use and
reordered some lines of code that were in a bad order.