cleaned up code for checking the status.