Refactored a bit and changed '1' to 'on' and '0' to 'off'.