refactored some of the code a bit to use the lst API.