changed logic added structures, total improvement