refactoring. converted several if/elses to ternary statements