added some logic on frontend