fix bug when setting keyframes near bounds
Fix edge cases