Updated

better logic