merged some code