Refactored code to get the blocked and scheduled hosts