add more logic back and front