Bug fix & changing loop + array_unshift to array_merge