split up js into more logical files, added error display