fix alarm threshold exceed when usage is at 0% and some code refactor