Replaced delays with proper polling for bytes