updated with proper code with NON-blocking approach