Restructured the code. made bitSequence class that handles the conversions.