added assertions and comments