Fix bug to detecting state of service