Solved problem 5.1 for inserting bits