divide render function into two other function