fixed a bug k being calculated too low