Fix bug in checking for before and after methods