merged some code,