Working on cleaning up JavaScript structure
got code cleaned up