refactoring code to work on github pages