added some better callback and array building