fixed bugs that appeared from nowhere. now matches simulink model