refactored count nights