Moving some code for readability