Tidy up registration javascript