refactored some initialisation code