attempted a better js structure