fix little problem with edge cases