fixed so it works + added basic comments