code refactoring + fix for redhat family