added some buggy trigonometry