Cleaned up render code