separated javascript code from html / cleaned up naming