mostly working version, submit takes 2-3 times