Moved the checking on interface statuses to a function