Added init function, avanti's code