refactored to use init function, magic-log