Add events handler
Import factorial