merged correct code, cleanup