changed confirm to custom one and minor code improvement