auto init function after attach