use if main block in entry points

closes #4698