Fixing typos and when statements