Simplified the creation and checking of guards

Simplified the creation and checking of guards; DRY