More Adhoc functions implemented

Are you sure you got the if-s and brackets right here? The next line is not indented properly so it's hard to tell what the intention is here.