fixed sorting and added cancel button