reformatted code
added smary array merge