logic for horse management