improve performance
simplify conditionals