refactored to use ternary operator and clean up spacing issues