optimized. time test added to compare with dict.