Remove hard coded array length

I removed hard coded array length from the code. It'll make your code more flexible.