Split render function in two