Added code for bar generation