fixing unexpected bugs and making better interface