moved module export outside if block