Fixed null pointer exception. Issue was with the order of evaluating length checks and null checks in sample merging. Have an issue with array out of bounds now