Moved stuff to a seperate method to keep things clean.