updated isDyckPath function