My attempt at fixing it.