Reorganizing the code a little bit