updated main()
added check