Initializing from thinakaran's code