changed to avoid ~~ operator for array comparison