Made returnBytes more error tolerant