refactored js functions for building and sorting schedule on public site