adding MergeImages function + code formatting