add security checks and postgresql support