This paper proposes, an efficient method for text independent writer identification using a codebook. The occurrence histogram of the shapes in the codebook is used to create a feature vector for the handwriting. There is a wide variety of different shapes in the connected components obtained from handwriting. Small fragments of connected components should be used to avoid complex patterns. A new and more efficient method is introduced for this purpose. To evaluate the methods, writer identification is conducted on three varieties of a Farsi database. These varieties include texts of short, medium and large lengths. Experimental results show the efficiency of the method especially for short texts. Keywords-writer identification; handwriting; Farsi; codebook;