Fixed a nasty variable shadowing bug :)