merged some functions together