Bug fixes

- export function
- fix for nested ifs