Simplified the Javascript