cleaned js sample code