switched to ternary operators
cleaned up code