cleaned up code part 1