Moved stuff to its own method