Fix issue #48

Additionally I made slight visual changes for coherence, and I renamed
the temp variable as suggested.