better array handling and logging