added support for loading - not completely finished and does contain bugs