Refactor code

Improves usage of conditional operator and constants.