extract autocmd & function handling to separate file