Moving some code around