some cleanup and an experiment with using a javascript object