move init to function