fixed bug in initialization for i,j values.. also simplified a bit