append extensions and some optimization