Split up code a little