split up render() into 3 dedicated functions