Cleaned up code, moved js to its own file