added init function and refactored headers