first half of bug fixed