First successful attempt at replicating hand-written solution for g1.