some refactoring of app for use on my site