Refactor code and place samples on window