Refactored code to make hard_limit simpler
Refactored code to make hard_limit simpler