fixed bugs in merge with ArrayList