Implement function using bitset