optomize code