Almost working homework