Fixes loop length