added some case check in javascript