Improve teh logics