cleaned up js code + autofill fields