rewrote major parts to reduce complexity. also changed language to english