Added loader file and moved code around