first commit, working starting point but needs tweaking, only tested in Chrome