refactored statement checking