Reestructuring the code a little