code for task#921 and task#916