fixes typos, simplifies code