fixed populate_row function