move related code together