I see similar statements above can be moved to a method.