fixed code bugs