refactored and added some dependencies etc.