fix optimization issues