Replace hack with correct code