refactor lb function
re-format and cached version of lb function