Fix logic error in array of struct