added generator building code