submission logic in js