Add constructor and improves safety