Tweaking code for readability/efficiency
Fixing bug