works now for nonzero potential