Moved related code closer together