Fixing undeclared variables
Changing ternary to proper conditional
Fixing line length

Lines should ideally be less than 85 characters