Fixed an 8-space indent.
Reworked logic a bit. Should work the same way.