fixed some bad code