Yes, its better to write a function. I will do that !